home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10101 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  78 lines

  1. Newsgroups: gnu.g++.help,comp.lang.c++
  2. Path: tank.news.pipex.net!pipex!warwick!nott-cs!trent-doc!news
  3. From: CHAMBERS Jason <pt3chaj>
  4. Subject: Re: IS THIS LEGAL? Static method returns pointer to class
  5. X-Nntp-Posting-Host: pup21
  6. Content-Type: multipart/mixed;
  7.     boundary="-------------------------------19997724768799091920253434"
  8. Message-ID: <Dnt85t.FGu@doc.ntu.ac.uk>
  9. Sender: news@doc.ntu.ac.uk
  10. Organization: The Nottingham Trent University, DOC.
  11. References: <4hdu70$efa@panix.com>
  12. Mime-Version: 1.0
  13. Date: Tue, 5 Mar 1996 19:44:17 GMT
  14. X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.2 sun4c)
  15. X-Url: news:4hdu70$efa@panix.com
  16.  
  17. This is a multi-part message in MIME format.
  18.  
  19. ---------------------------------19997724768799091920253434
  20. Content-Transfer-Encoding: 7bit
  21. Content-Type: text/plain; charset=us-ascii
  22.  
  23. At line 10, surely Trianlge should be Triangle?
  24.  
  25. ---------------------------------19997724768799091920253434
  26. Content-Transfer-Encoding: 7bit
  27. Content-Type: text/plain
  28.  
  29. From: acinader@panix.com (Arthur Cinader Jr)
  30. Newsgroups: gnu.g++.help,comp.lang.c++
  31. Subject: IS THIS LEGAL? Static method returns pointer to class
  32. Date: 4 Mar 1996 00:14:08 -0500
  33. Organization: Panix
  34. Message-ID: <4hdu70$efa@panix.com>
  35.  
  36. I may be going at this wrong, but I want to have a class
  37. Triangle contain a static method called makeinstance.  The
  38. method will be passed a refernce to a Param object that has
  39. a list of parameters for checking first and then passing to 
  40. the Triangle constructor.
  41.  
  42. The parameters are checked and if all is ok, a Triangle
  43. instance is "newed" and the pointer to the new Trinagle is
  44. returned.  When I compile, I get the following error:
  45.  
  46. % g++ -c triangle.C
  47. In file included from triangle.C:8:
  48. triangle.h:17: syntax error before `*'
  49. ..
  50. %
  51.  
  52. ***The declaration for the class:
  53.  
  54.       1 // triangle.h
  55.       2 // declaration of class Triangle extends shape
  56.       3
  57.       4 #ifndef TRIANGLE_H
  58.       5 #define TRIANGLE_H
  59.       6
  60.       7 #include "point.h"
  61.       8 #include "param.h"
  62.       9
  63.      10 class Trianlge : public Point {
  64.      11 public:
  65.      12     Trinagle(float = 0.0, float = 0.0, float = 0.0);
  66.      13     float gets() const;
  67.      14     virtual void draw() const;
  68.      15
  69.      16     static Param &getParams();
  70.      17     static Triangle *makeinstance(Param &);
  71.      18 private:
  72.      19     float side;
  73.      20 };
  74.      21
  75.      22 #endif
  76.  
  77. ---------------------------------19997724768799091920253434--
  78.